#pragma once
#pragma warning( disable: 4251 ) 

//WGLENGINE_DLL
#ifdef WGLENGINE_DLL
#define WGLENGINE_EXPORT __declspec(dllexport)
#else
#define WGLENGINE_EXPORT __declspec(dllimport)
#endif

#include "Shader.h"

#include <iostream>

#include <map>
#include <memory>
#include <string>
#include <vector>

#include "glm\glm.hpp"

class Texture;
class WGLENGINE_EXPORT Material
{
public:
	std::string name;
	std::shared_ptr<Shader> shader;
	
	bool castShadow;
	bool useShadowMap;
public:
	Material(std::string name, std::shared_ptr<Shader> shader = nullptr);
	Material(std::string name, bool useShadowMap = true, bool castShadow = true, std::shared_ptr<Shader> shader = nullptr);
	~Material();

	void Bind();
	void Unbind();
	
	static std::map<int, std::string> materialsNames;
	static std::map<std::string, std::shared_ptr<Material>> materials;
	
	static std::shared_ptr<Material> GetMaterial(const std::string& name)
	{
		if(materials.count(name) > 0)
		{
			return materials.at(name);
		}

#if _DEBUG
		std::cout<<"Material " << name << " not found." << std::endl;
#endif
		return nullptr;
	}

	static void AddMaterial(const std::string& name, std::shared_ptr<Material> material)
	{
		if(materials.count(name) == 0)
		{
			materials[name] = material;
			return;
		}
		
#if _DEBUG
		std::cout<<"Material " << name << " already exists." << std::endl;
#endif
	}

	std::shared_ptr<Shader> GetShader()
	{
		return shader;
	}
	/*
	void AddParameter(std::string name, float parameter);
	void AddParameter(std::string name, glm::vec2 parameter);
	void AddParameter(std::string name, glm::vec3 parameter);
	void AddParameter(std::string name, void* uniformBlock, GLuint size, GLuint bindingPt);

	void AddParameter(Shader::TextureType type, std::shared_ptr<Texture> texParameter);*/
};